<?php

use Illuminate\Database\Seeder;
use App\Role;
use App\Permission;
use \Illuminate\Support\Facades\DB;

class RoleSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $admin_sign_in = Permission::whereName('admin_sign_in')->first();
        if(!$admin_sign_in){
            Permission::firstOrCreate([
                'name'          => 'admin_sign_in',
                'display_name'  => '登录',
                'group'         => 'system',
                'description'   => ''
            ]);
        }

        $admin_list_select = Permission::whereName('admin_list_select')->first();
        if(!$admin_list_select){
            Permission::firstOrCreate([
                'name' => 'admin_list_select',
                'display_name' => '管理员查看',
                'group' => 'system',
                'description' => ''
            ]);
        }

        $admin_edit = Permission::whereName('admin_edit')->first();
        if(!$admin_edit){
            Permission::firstOrCreate([
                'name' => 'admin_edit',
                'display_name' => '管理员编辑',
                'group' => 'system',
                'description' => ''
            ]);
        }

        $admin_delete = Permission::whereName('admin_delete')->first();
        if(!$admin_delete){
            Permission::firstOrCreate([
                'name' => 'admin_delete',
                'display_name' => '管理员删除',
                'group' => 'system',
                'description' => ''
            ]);
        }

        $role_list_select = Permission::whereName('role_list_select')->first();
        if(!$role_list_select){
            Permission::firstOrCreate([
                'name' => 'role_list_select',
                'display_name' => '角色查看',
                'group' => 'system',
                'description' => ''
            ]);
        }

        $role_edit = Permission::whereName('role_edit')->first();
        if(!$role_edit){
            Permission::firstOrCreate([
                'name' => 'role_edit',
                'display_name' => '角色编辑',
                'group' => 'system',
                'description' => ''
            ]);
        }

        $role_delete = Permission::whereName('role_delete')->first();
        if(!$role_delete){
            Permission::firstOrCreate([
                'name' => 'role_delete',
                'display_name' => '角色删除',
                'group' => 'system',
                'description' => ''
            ]);
        }

        $permission_select = Permission::whereName('permission_select')->first();
        if(!$permission_select){
            Permission::firstOrCreate([
                'name' => 'permission_select',
                'display_name' => '权限查看',
                'group' => 'system',
                'description' => ''
            ]);
        }

        $teacher_list_select = Permission::whereName('teacher_list_select')->first();
        if(!$teacher_list_select){
            Permission::firstOrCreate([
                'name'          => 'teacher_list_select',
                'display_name'  => '导师查看',
                'group'         => 'teacher',
                'description'   => ''
            ]);
        }

        $teacher_edit = Permission::whereName('teacher_edit')->first();
        if(!$teacher_edit){
            Permission::firstOrCreate([
                'name'          => 'teacher_edit',
                'display_name'  => '导师编辑',
                'group'         => 'teacher',
                'description'   => ''
            ]);
        }

        $teacher_delete = Permission::whereName('teacher_delete')->first();
        if(!$teacher_delete){
            Permission::firstOrCreate([
                'name'          => 'teacher_delete',
                'display_name'  => '导师删除',
                'group'         => 'teacher',
                'description'   => ''
            ]);
        }

        $course_list_select = Permission::whereName('course_list_select')->first();
        if(!$course_list_select){
            Permission::firstOrCreate([
                'name'          => 'course_list_select',
                'display_name'  => '课程查看',
                'group'         => 'course',
                'description'   => ''
            ]);
        }

        $course_edit = Permission::whereName('course_edit')->first();
        if(!$course_edit){
            Permission::firstOrCreate([
                'name'          => 'course_edit',
                'display_name'  => '课程编辑',
                'group'         => 'course',
                'description'   => ''
            ]);
        }

        $course_delete = Permission::whereName('course_delete')->first();
        if(!$course_delete){
            Permission::firstOrCreate([
                'name'          => 'course_delete',
                'display_name'  => '课程删除',
                'group'         => 'course',
                'description'   => ''
            ]);
        }

        $course_type_list_select = Permission::whereName('course_type_list_select')->first();
        if(!$course_type_list_select){
            Permission::firstOrCreate([
                'name'          => 'course_type_list_select',
                'display_name'  => '课程类型查看',
                'group'         => 'course',
                'description'   => ''
            ]);
        }

        $course_type_edit = Permission::whereName('course_type_edit')->first();
        if(!$course_type_edit){
            Permission::firstOrCreate([
                'name'          => 'course_type_edit',
                'display_name'  => '课程类型编辑',
                'group'         => 'course',
                'description'   => ''
            ]);
        }

        $course_type_delete = Permission::whereName('course_type_delete')->first();
        if(!$course_type_delete){
            Permission::firstOrCreate([
                'name'          => 'course_type_delete',
                'display_name'  => '课程类型删除',
                'group'         => 'course',
                'description'   => ''
            ]);
        }

        $order_list_select = Permission::whereName('order_list_select')->first();
        if(!$order_list_select){
            Permission::firstOrCreate([
                'name'          => 'order_list_select',
                'display_name'  => '订单查看',
                'group'         => 'order',
                'description'   => ''
            ]);
        }

        $staff_list_select = Permission::whereName('staff_list_select')->first();
        if(!$staff_list_select){
            Permission::firstOrCreate([
                'name'          => 'staff_list_select',
                'display_name'  => '人员查看',
                'group'         => 'staff',
                'description'   => ''
            ]);
        }

        $staff_edit = Permission::whereName('staff_edit')->first();
        if(!$staff_edit){
            Permission::firstOrCreate([
                'name'          => 'staff_edit',
                'display_name'  => '人员编辑',
                'group'         => 'staff',
                'description'   => ''
            ]);
        }

        $staff_delete = Permission::whereName('staff_delete')->first();
        if(!$staff_delete){
            Permission::firstOrCreate([
                'name'          => 'staff_delete',
                'display_name'  => '人员删除',
                'group'         => 'staff',
                'description'   => ''
            ]);
        }

        $coupon_list_select = Permission::whereName('coupon_list_select')->first();
        if(!$coupon_list_select){
            Permission::firstOrCreate([
                'name'          => 'coupon_list_select',
                'display_name'  => '优惠券查看',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $coupon_edit = Permission::whereName('coupon_edit')->first();
        if(!$coupon_edit){
            Permission::firstOrCreate([
                'name'          => 'coupon_edit',
                'display_name'  => '优惠券编辑',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $coupon_delete = Permission::whereName('coupon_delete')->first();
        if(!$coupon_delete){
            Permission::firstOrCreate([
                'name'          => 'coupon_delete',
                'display_name'  => '优惠券删除',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $course_package_list_select = Permission::whereName('course_package_list_select')->first();
        if(!$course_package_list_select){
            Permission::firstOrCreate([
                'name'          => 'course_package_list_select',
                'display_name'  => '课程套餐查看',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $course_package_edit = Permission::whereName('course_package_edit')->first();
        if(!$course_package_edit){
            Permission::firstOrCreate([
                'name'          => 'course_package_edit',
                'display_name'  => '课程套餐编辑',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $course_package_delete = Permission::whereName('course_package_delete')->first();
        if(!$course_package_delete){
            Permission::firstOrCreate([
                'name'          => 'course_package_delete',
                'display_name'  => '课程套餐删除',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $group_activity_list_select = Permission::whereName('group_activity_list_select')->first();
        if(!$group_activity_list_select){
            Permission::firstOrCreate([
                'name'          => 'group_activity_list_select',
                'display_name'  => '拼团活动查看',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $group_activity_edit = Permission::whereName('group_activity_edit')->first();
        if(!$group_activity_edit){
            Permission::firstOrCreate([
                'name'          => 'group_activity_edit',
                'display_name'  => '拼团活动编辑',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $group_activity_delete = Permission::whereName('group_activity_delete')->first();
        if(!$group_activity_delete){
            Permission::firstOrCreate([
                'name'          => 'group_activity_delete',
                'display_name'  => '拼团活动删除',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $clue_list_select = Permission::whereName('clue_list_select')->first();
        if(!$clue_list_select){
            Permission::firstOrCreate([
                'name'          => 'clue_list_select',
                'display_name'  => '线索查看',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $clue_edit = Permission::whereName('clue_edit')->first();
        if(!$clue_edit){
            Permission::firstOrCreate([
                'name'          => 'clue_edit',
                'display_name'  => '线索编辑',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }

        $clue_delete = Permission::whereName('clue_delete')->first();
        if(!$clue_delete){
            Permission::firstOrCreate([
                'name'          => 'clue_delete',
                'display_name'  => '线索删除',
                'group'         => 'marketing',
                'description'   => ''
            ]);
        }
    }
}
